import type { Feature, Point, LineString, Polygon } from 'geojson'
import {
  primaryHighLightFillStyle,
  primaryHighLightLineStyle,
  primaryHighLightSymbolStyle,
  secondaryHighLightFillStyle,
  secondaryHighLightLineStyle,
  secondaryHighLightSymbolStyle,
  tertiaryHighLightFillStyle,
  tertiaryHighLightLineStyle,
  tertiaryHighLightSymbolStyle
} from './styles'
import {
  asFillFeature,
  asLineFeature,
  asSymbolFeature,
  fillProperties,
  lineProperties,
  symbolProperties
} from '../layer'

export const highlightSymbolFeature = {
  primary(feature: Feature<Point>, txt: string | undefined) {
    return asSymbolFeature(feature, txt, primaryHighLightSymbolStyle)
  },
  secondary(feature: Feature<Point>, txt: string | undefined) {
    return asSymbolFeature(feature, txt, secondaryHighLightSymbolStyle)
  },
  tertiary(feature: Feature<Point>, txt: string | undefined) {
    return asSymbolFeature(feature, txt, tertiaryHighLightSymbolStyle)
  }
}

export const highlightLineFeature = {
  primary: (feature: Feature<LineString | Polygon>) =>
    asLineFeature(feature, primaryHighLightLineStyle),
  secondary: (feature: Feature<LineString | Polygon>) =>
    asLineFeature(feature, secondaryHighLightLineStyle),
  tertiary: (feature: Feature<LineString | Polygon>) =>
    asLineFeature(feature, tertiaryHighLightLineStyle)
}

export const highlightFillFeature = {
  primary: (feature: Feature<Polygon>) => asFillFeature(feature, primaryHighLightFillStyle),
  secondary: (feature: Feature<Polygon>) => asFillFeature(feature, secondaryHighLightFillStyle),
  tertiary: (feature: Feature<Polygon>) => asFillFeature(feature, tertiaryHighLightFillStyle)
}

export const highLightFeature = {
  symbol: highlightSymbolFeature,
  line: highlightLineFeature,
  fill: highlightFillFeature
}

export const highLightProperties = {
  symbol: {
    primary: (txt: string | undefined, icon: string | undefined = undefined) =>
      symbolProperties(txt, primaryHighLightSymbolStyle, icon),
    secondary: (txt: string | undefined, icon: string | undefined = undefined) =>
      symbolProperties(txt, secondaryHighLightSymbolStyle, icon),
    tertiary: (txt: string | undefined, icon: string | undefined = undefined) =>
      symbolProperties(txt, tertiaryHighLightSymbolStyle, icon)
  },
  line: {
    primary: lineProperties(primaryHighLightLineStyle),
    secondary: lineProperties(secondaryHighLightLineStyle),
    tertiary: lineProperties(tertiaryHighLightLineStyle)
  },
  fill: {
    primary: fillProperties(primaryHighLightFillStyle),
    secondary: fillProperties(secondaryHighLightFillStyle),
    tertiary: fillProperties(tertiaryHighLightFillStyle)
  }
}
